/*
 * Vector3f.cpp
 *
 *  Created on: 08.12.2011
 *      Author: tim
 */

#include "Vector3f.hpp"

Vector3f::Vector3f() {
	m_x = 0;
	m_y = 0;
	m_z = 0;
}

Vector3f::Vector3f(float x, float y, float z) {
	m_x = x;
	m_y = y;
	m_z = z;
}

Vector3f::Vector3f(Vector3f &v) {
	this->m_x = v.m_x;
	this->m_y = v.m_y;
	this->m_z = v.m_z;
}

void Vector3f::normalize(void) {
	this = this / this->absolute_Value();
}

Vector3f Vector3f::operator +(Vector3f &v2) {
	return Vector3f(this->m_x + v2.m_x,
					this->m_y + v2.m_y,
					this->m_z + v2.m_z);
}

Vector3f Vector3f::operator -(Vector3f &v2) {
	return Vector3f(this->m_x - v2.m_x,
					this->m_y - v2.m_y,
					this->m_z - v2.m_z);
}

Vector3f Vector3f::operator *(Vector3f &v2) {
	return Vector3f(this->m_x * v2.m_x,
					this->m_y * v2.m_y,
					this->m_z * v2.m_z);
}

Vector3f Vector3f::operator +=(Vector3f &v2) {
	return this + v2;
}

Vector3f Vector3f::operator -=(Vector3f &v2) {
	return this - v2;
}

Vector3f Vector3f::operator *=(Vector3f &v2) {
	return this * v2;
}

Vector3f Vector3f::operator *(float f) {
	return Vector3f(this->m_x * f, this->m_y * f, this->m_z * f);
}

Vector3f operator *(float f, Vector3f v2) {
	return v2 * f;
}

Vector3f Vector3f::operator /(float f) {
	return *Vector3f(this->m_x / f, this->m_y / f, this->m_z / f);
}

Vector3f Vector3f::operator *=(float f) {
	return this * f;
}

Vector3f Vector3f::operator /=(float f) {
	return this / f;
}

float Vector3f::operator [](int i) {
	switch (i) {
		case 1: return this->m_x; break;
		case 2: return this->m_y; break;
		case 3: return this->m_z; break;
		default: return 0;
	}
}

Vector3f Vector3f::operator =(Vector3f &v2) {
	return Vector3f(v2);
}

float Vector3f::absolute_Value(void) {
	return std::sqrt(this->m_x * this->m_x +
			 	 	 this->m_y * this->m_y +
			 	 	 this->m_z * this->m_z);
}

